package dao

import (
	"github.com/go-redis/redis"
	"runtime"
	"shop/config"
)

var redisCli = initRedis()

func initRedis() *redis.Client {
	return redis.NewClient(&redis.Options{
		Addr:     config.Conf.RedisAddress,
		Password: config.Conf.RedisPassword,
		DB:       0,
		// 连接池配置
		PoolSize:     runtime.NumCPU() * 10,
		MinIdleConns: 5 + runtime.NumCPU(),
	})
}

func GetRedisCli() *redis.Client {
	return redisCli
}
